package com.yugao.fintech.libra.shortlink.model.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yugao.fintech.libra.common.model.BasePO;
import com.yugao.fintech.libra.common.tenant.core.DataIsolation;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 访问日志
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("sl_access_log")
@DataIsolation(filterTenant = true, tableName = "sl_access_log")
public class AccessLog extends BasePO {
    @TableId
    private Long id;

    /**
     * 短链码
     */
    private String code;
    /**
     * 组id
     */
    private Long groupId;

    /**
     * 域名id
     */
    private Long domainId;

    /**
     * ip地址
     */
    private String ip;

    /**
     * 操作系统
     */
    private String os;

    /**
     * 浏览器
     */
    private String browser;

    /**
     * 租户id
     */
    private Long tenantId;

    /**
     * 创建时间, 也是访问时间
     */
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createdAt;

    public static LambdaQueryWrapper<AccessLog> lqw() {
        return Wrappers.lambdaQuery();
    }
}
